feat(trade): shared market data subscriptions, bounded cache, and typed order events (OB-111, OB-109, OB-110, OB-112) - #799
Merged
IbrahimIjai merged 2 commits intoSep 26, 2026
Conversation
…ed order events (OB-111, OB-109, OB-110, OB-112) - Manage one shared market-data subscription per active source with consumer reference-counting and bounded polling fallback (OB-111) - Bound inactive cache retention and server-state duplication across long sessions (OB-109) - Add cache correctness, scope isolation, and request-deduplication regression coverage (OB-110) - Replace loose order-event polling with typed event decoding, multi-page burst pagination, and cursor persistence (OB-112)
|
@Prudentdev-xyz is attempting to deploy a commit to the Ijai's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Prudentdev-xyz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #766
Closes #764
Closes #765
Closes #767
Comprehensive implementation addressing real-time market data subscriptions, query cache retention bounds, cache correctness regression testing, and typed contract order-event processing across 4 interconnected issues:
OB-111: Manage one shared market-data subscription per active source (#766)
marketSubscriptionManagerto manage a single shared connection per active symbol with subscriber reference counting.useOrderBook,useRecentTrades, anduseLiveBarshare the same underlying connection. Mounting/unmounting panels (e.g. toggling tabs in OrderBookPanel) does not multiply WebSocket connections or timers."polling"inDepthLadderandRecentTradesTape.OB-109: Bound cache retention and server-state duplication (#764)
staleTimeandgcTimelimits incache-policy.ts(MARKET_DATA: 30s/5m,REALTIME_TAPE: 2s/1m,ACCOUNT_FINANCIAL: 5s/2m,HISTORY: 30s/3m).boundQueryCachetoQueryProvider, ensuring inactive queries across extended sessions with repeated market/account switches are pruned and capped (max 50 inactive queries).wallet-store; addedpendingTransactionTimestampwith a 15-minute max age check to ensure pending execution state is not blindly hydrated as truth.cache-retention-long-session.md.OB-110: Add cache correctness and request-deduplication regression coverage (#765)
cache-correctness.test.tsxtesting combined cache policies via network/data behavior rather than isolated spy checks.OB-112: Replace loose order-event polling with typed cursor processing (#767)
useOrderEventPolling.tswith typed event querying viaqueryContractEvents.order-event-decoder.tsto decode contract topics and payloads, matching account addresses strictly.so4:order-events:cursor:${account}); advances cursor only after successful page processing.OrderExecutedto positions/orders/balances/market stats,OrderCancelledandOrderCreatedto orders/balances, andOrderUpdatedto orders.useOrderEventPolling.test.tscovering bursts, restart recovery, deduplication, malformed events, and failure handling.Changes
Modified Files
apps/web/src/app/providers/QueryProvider.tsxapps/web/src/features/trade/hooks/useOrderBook.tsapps/web/src/features/trade/hooks/useRecentTrades.tsapps/web/src/features/trade/hooks/useLiveBar.tsapps/web/src/features/trade/hooks/useOrderEventPolling.tsapps/web/src/features/trade/components/orderbook/DepthLadder.tsxapps/web/src/features/trade/components/orderbook/RecentTradesTape.tsxapps/web/src/features/wallet/store/wallet-store.tsNew Files
apps/web/src/features/trade/lib/market-data-stream.tsapps/web/src/features/trade/lib/market-data-stream.test.tsapps/web/src/features/trade/lib/cache-policy.tsapps/web/src/features/trade/lib/cache-correctness.test.tsxapps/web/src/features/trade/lib/cache-retention-long-session.mdapps/web/src/features/trade/lib/order-event-decoder.tsapps/web/src/features/trade/hooks/useOrderEventPolling.test.ts.changelog/unreleased/766-shared-market-data-cache-order-events.md